package main

import "sort"

func majorityElement(nums []int) int {
    length:=len(nums)
    countMap :=make(map[int]int,length)
    for _,val:=range nums{
		if _,ok :=countMap[val];ok{
			countMap[val]+=1
		}else {
			countMap[val]=1
		}
		if countMap[val]>len(nums)/2 {
			return val
		}
    }
    return 0
}
// 这一题目比较简单
func majorityElement(nums []int) int {
	sort.Ints(nums)
	return nums[len(nums)/2]
}

func main() {

}
